<?php

class DateUtil
{
    /*
     * 获取现在时间
     */
    public static  function getNowTime()
    {
        return DateUtil::getCurrentDateFormat(8);
    }

    public static  function getNowDay()
    {
        return gmdate('Y-m-d',time()+3600*8);
    }

    /*
     * 获取现在时间之后秒数
     */
    public static  function getNowTimeAfter($seconds)
    {
        return gmdate('Y-m-d H:i:s',time()+3600*8+$seconds);
    }

	public static function GetCurrentUTCDateTime()
	{
		return DateUtil::getCurrentDateFormat(8);
	}
	
	public static function getCurrentDateFormat($zone)
	{
		return gmdate('Y-m-d H:i:s',time()+3600*$zone);
		
	}
	
	public static function getTodayDate()
	{
		//return date('Y-m-d H:i:s',time());
		return gmdate('Ymd',time()+3600*8);
	}
	public static function getTodayDateUserInDB()
	{
		//return date('Y-m-d H:i:s',time());
		return gmdate('Y-m-d',time()+3600*8);
	}
	
	public static function getUnixTimeStampByZero($zone)
	{
		return time()-3600*$zone;
	}
	
	public static function getAfterNDayTime($N)
	{
		return gmdate('Y-m-d H:i:s',time()+3600*24*$N);
	}
    
    public static function getTheMonth($date)
    {
        $firstday = date('Y-m-01 00:00:00', strtotime($date));
        $lastday = date('Y-m-d 23:59:59', strtotime("$firstday +1 month -1 day"));
        return array($firstday,$lastday);
    }
    
    public static function getCorrectUTCTime($time)
    {
        $ctime = strtotime($time);
        $now = time() + 300;
        
        if($ctime > $now)
        {
            return DateUtil::GetCurrentUTCDateTime();
        }else
            return $time;
    }

    /*
     * 时间比较
     */
    public static function compareTime($time1,$time2)
    {

    }

    public static function getDayByDatetime($datetime)
    {
        return substr($datetime,0,10);
    }
}
